/*
 *--------------------------------------------------------------------------
 *   Battlefield - A Realtime Network Multiplayer Game
 *   =======================================================
 *   Developed by Group D02 - 2009/2010 Semester 4 - CS2103
 *     Harry Nguyen Duy Hoang <nnduyhoang@yahoo.co.uk>
 *     Kent Chng Siang Rong <fivefootway@gmail.com>
 *     Lim Yong Peng <limpeng1986@gmail.com>
 *     Loh Xiankun <u0807185@nus.edu.sg>
 *   Instructed by
 *     Dr. Damith C.Rajapakse <damith@gmail.com>
 *   =======================================================
 *   $Id: Session.java 579 2010-07-26 12:23:07Z YongPeng $
 *   $LastChangedDate: 2010-07-26 12:23:07 +0000 (Mon, 26 Jul 2010) $
 *   $LastChangedBy: YongPeng $
 *--------------------------------------------------------------------------
 */
package battlefield.entity;

import java.io.Serializable;
import java.util.UUID;

/**
 *
 * @author Harry Nguyen
 */
public class Session implements Serializable {

    private UUID id;
    private Player player;
    private Player opponent;
    private Game game;
    private String playerName = "Player1";
    private String ipAddress;
    private int goldReloadDuration;
    private int goldReloadAmt;
    private int startGold;

    /**
     * Constructs the Session object with the following parameters
     * @param id unique id for the session object
     */
    public Session(UUID id) {
        this.id = id;
    }

    /**
     * Returns the id of the session object
     * @return the UUID object
     */
    public UUID getId() {
        return id;
    }

    /**
     * Returns the Player object using this session
     * @return Player object
     */
    public Player getPlayer() {
        return player;
    }

    /**
     * Sets the player using this session
     * @param player using this session
     */
    public void setPlayer(Player player) {
        this.player = player;
    }

    /**
     * Returns the Player's opponent
     * @return Player object
     * @see Player
     */
    public Player getOpponent() {
        return opponent;
    }

    /**
     * Sets the opponent of the player
     * @param opponent Player object 
     */
    public void setOpponent(Player opponent) {
        this.opponent = opponent;
    }

    /**
     * Returns the Game object of the session
     * @return Game object
     */
    public Game getGame() {
        return game;
    }

    /**
     * Sets the Game object of this session
     * @param game
     */
    public void setGame(Game game) {
        this.game = game;
    }

    /**
     * Returns the name of the player using this session
     * @return String name of the player
     */
    public String getPlayerName() {
        return playerName;
    }

    /**
     * Sets the player name using this session
     * @param playerName
     */
    public void setPlayerName(String playerName) {
        this.playerName = playerName;
    }

    /**
     * Returns the starting gold for this player
     * @return int
     */
    public int getStartGold() {
        return startGold;
    }

    /**
     * Sets the starting gold for this player
     * @param startGold
     */
    public void setStartGold(int startGold) {
        this.startGold = startGold;
    }

    /**
     * Returns the amount of gold to reload
     * @return int
     */
    public int getGoldReloadAmount() {
        return goldReloadAmt;
    }

    /**
     * Sets the amount of gold to reload
     * @param goldReloadAmt
     */
    public void setGoldReloadAmount(int goldReloadAmt) {
        this.goldReloadAmt = goldReloadAmt;
    }

    /**
     * Returns the duration before gold is reloaded
     * @return int
     */
    public int getGoldReloadDuration() {
        return goldReloadDuration;
    }

    /**
     * Sets the duration before the gold is reloaded
     * @param goldReloadDuration
     */
    public void setGoldReloadDuration(int goldReloadDuration) {
        this.goldReloadDuration = goldReloadDuration;
    }

    /**
     * Sets the ip address of the host
     * @param ipAddress
     */
    public void setIpAddress(String ipAddress) {
        this.ipAddress = ipAddress;
    }

    /**
     * Returns the ip address of the host
     * @return String
     */
    public String getIpAddress() {
        return ipAddress;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }

        if (!(obj instanceof Session)) {
            return false;
        }

        return ((Session) obj).getId().equals(this.getId());
    }
}
